package com.scott.crm.role;

import com.scott.crm.role.bean.RoleBean;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 黄后林
 * @version 1.0
 * @note
 * @date 2021-12-04 21:54:44
 */
@Component
public class RoleDao {

    public RoleBean findRoleById(Integer id) {
        //1、使用roleList来模拟角色表 里面有2条记录 每条记录有3个字段
        List<RoleBean> roleList = new ArrayList<>();
        RoleBean teacher = new RoleBean(20010,"老师","teacher");
        RoleBean student = new RoleBean(20020,"学生","student");
        roleList.add(teacher);
        roleList.add(student);

        //2、模拟角色id查找角色
        for(RoleBean role : roleList){
            Integer roleId= role.getRoleId();
            if(id.equals(roleId)){
                return role;
            }
        }
        return null;
    }
}
